//
//  LauEmoticonPageModel.swift
//  表情包数据
//
//  Created by Lausen on 2017/5/17.
//  Copyright © 2017年 id. All rights reserved.
//

import UIKit
import YYModel


class LauEmoticonPageModel: NSObject {

    lazy var emoticons = [LauEmotionModel]()
    
    /// 组名
    var groupName: String?
    /// 文件的路径
    var directory: String?{
        
        didSet{
            
            guard let directory = directory,
                  let path = Bundle.main.path(forResource: "Emoticons.bundle", ofType: nil),
                  let bundle = Bundle.init(path: path),
                  // 因为是在bundle下面两个级层,所以要制定一下最后一级的名称
                  let emoticonPath = bundle.path(forResource: "info.plist", ofType: nil, inDirectory: directory),
                  let array = NSArray(contentsOfFile: emoticonPath),
                  let models = NSArray.yy_modelArray(with: LauEmotionModel.self, json: array) as? [LauEmotionModel]
                else {
                
                return
            }
            
            emoticons += models
            
            for emoticon in emoticons {
                
                emoticon.directory = directory
            }
        }
    }
    
    override var description: String{
        
        return yy_modelDescription()
    }
    
}
